import { createRouter, createWebHashHistory } from 'vue-router'
import { DefineComponent } from "vue"

import Home from '@/views/home/Home.vue'
import NotFound from '@/views/404/NotFound.vue'

import Cart from '@/views/cart/Cart.vue'

import User from '@/views/user/User.vue'
import Login from '@/views/login/Login.vue'
import AddCart from '@/views/AddCart/AddCart.vue'


import Detail from '@/views/detail/Detail.vue';


import Address from '@/views/address/Address.vue';

type RoutesObj = {
    path: string
    name?: string
    component?: DefineComponent<{}, {}, any>
    children?: string[],
    redirect?: string
}


const routes = [
    { path: '/', redirect: '/login' },
    { path: '/home', name: 'home', component: Home },
    { path: '/cart', name: 'cart', component: Cart },
    { path: '/user', name: 'user', component: User },

    { path: '/login', name: 'login', component: Login },
    { path: '/addcart', name: 'addcart', component: AddCart },
    { path: '/detail/:id', name: 'detail', component: Detail },


    { path: '/address', name: 'address', component: Address },


    { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },
]

const router: any = createRouter({
    routes: routes,
    history: createWebHashHistory()
})

export default router 